url = 'https://www.acwing.com/problem/content/797/'

n,m = map(int,input().split())

data = list(map(int,input().split()))

res = [0]

for d in data:
    res.append(d+res[-1])

for i in range(m):
    l,r = map(int,input().split())

    print(res[r] - res[l-1])
